<extend name="layout/main" />

<block name="HEADER">
	
</block>

<block name="CONTENT">
	<control:grid id="grid"/>
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns){
     
		    //页面初始化
		    ns.init=function(){

		    }
		    
		    
		    //新增
		    ns.add=function(){
		    	var filter = {
		            url:"system/member/index/edit",
		            oid:"",
		            mode:1
		        }
		        $.openIframe(filter, "新增",['500px', '520px']);
		    }
		    
		    //编辑
		    ns.edit=function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url:"system/member/index/edit",
		            oid: selectedRow.id ,
		            mode:2
		        }
		        $.openIframe(filter, "编辑",['500px', '520px']);
		    }  
		    
		    //删除
		    ns.del =function(){
		    	if( !grid.isSelected() ){
		    		return false;
		    	}
		    	$.confirm("确定删除？", function(){
		    		$.ajaxs('/admin/v1/Spread/del',{
			    		ids:grid.getSelectedColumnValue('id')
			    	},function(res){
			    		$.toast(1,"已删除！");
			    		grid.load();
			    	});
		    	});
		    }
		    
		    //下拉移动  type: 1 = 上移 ,  type: 2 = 下移
		    ns.move = function(type){
		    	grid.adjustSort(type,"sort_no");
		    }
		    
		    //启用禁用
		    ns.setJoin =function(state){
		    	if( !grid.isSelected() ){
		    		return false;
		    	}
		    	$.confirm("确定" + (state == "1" ? "参加?" : "移出活动?"),function(index){
			    	$.ajaxs("/admin/v1/user/setJoin",{
			    	 	ids: grid.getSelectedColumnValue("id"),
			    	 	state: state 
			    	},function(res){
			            grid.load();      
			        });
			        layer.close(index);
		        });
		    }
		    
		    //启用禁用
		    ns.delAgent =function(){
		    	if( !grid.isSelected() ){
		    		return false;
		    	}
		    	$.confirm("确定删除代理商资质？",function(index){
			    	$.ajaxs("/admin/v1/user/setJoin",{
			    	 	ids: grid.getSelectedColumnValue("id"),
			    	 	state: state 
			    	},function(res){
			            grid.load();      
			        });
			        layer.close(index);
		        });
		    }
		    
		    
		    return ns;
		}({}));
		
		
		$(function(){ page.init();  });

	</script>
</block>